﻿/******************************************************************************************************************************
 * Form that allows the user to view all of the details of a selected recipe that has been stored by the RecipeBox application
 * Author: Morgan Davis
 * Northwestern Michigan College (student assignment)
 * Created: 27 November 2013
 * ****************************************************************************************************************************/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RecipeBox
{
    public partial class frmViewRecipe : Form
    {
        public frmViewRecipe()
        {
            InitializeComponent();
        }
        public frmViewRecipe(Recipe recipe)
        {
            InitializeComponent();
            try
            {
                this.Text = recipe.name; //Recipe name appears as form header/title
                label2.Text = recipe.creditedCook;

                foreach (var x in recipe.instructions) //populate the instructions list box
                {
                    listBox1.Items.Add(x.ToString());
                }

                foreach (var x in recipe.ingredients) //populate the ingredients list box
                {
                    listBox2.Items.Add(x.ToString());
                }
            }
            catch (Exception)
            {
                MessageBox.Show("The recipe couldn't be loaded, an error has occured.", "Sorry About that!");
            }
        }
    }
}
